<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="static/css/jquery.circliful.css" rel="stylesheet" type="text/css" />
<style>
#thcolor {
	color: blue;
	background: -webkit-linear-gradient(#FFFFFF, #E0ECFF);
	/* Safari 5.1 - 6.0 */
	background: -o-linear-gradient(#FFFFFF, #E0ECFF);
	/* Opera 11.1 - 12.0 */
	background: -moz-linear-gradient(#FFFFFF, #E0ECFF);
	/* Firefox 3.6 - 15 */
	background: linear-gradient(#FFFFFF, #E0ECFF); /* 标准的语法（必须放在最后） */
}

#tab_shadow {
	box-shadow: 2px 2px 5px #888888;
	width: 400px;
	height: auto;
	font-size: 15px;
}

table th {
	color: #1D212B;
}

table td {
	color: #292F3D;
	padding: 5px 2px;
}

#tab_shadow2 {
	width: 400px;
}
</style>

<div id="cipan" style="position: absolute; left: 170px; top: 370px;">
	选择盘符：
	<div id="fenqu" style="position: absolute; left: 56px; top: 0px;"></div>
</div>


<div style="position: absolute; left: 115px; top: 410px; z-index: 0;">
	<div id="chart_container" style="width: 350px; height: 150px;"></div>
</div>

<div style="position: absolute; left: 90px; top: 135px; color: FF1188;">
	<table id="tab_shadow" bordercolor="#95B8E7" border="1" cellpadding=1px; cellspacing=0px;>
		<tr bgcolor=#000000;>
			<th id="thcolor" colspan="2">&nbsp;当前环境状态</th>
		</tr>

		<tr>
			<th>&nbsp;当前操作系统</th>
			<td id="SystemName"></td>
		</tr>

		<tr>
			<th>&nbsp;当前用户名</th>
			<td>${Session.SESSION_USER.f_pu_name}</td>
		</tr>
		<tr>
			<th>&nbsp;当前系统版本</th>
			<td id="systemVersion"></td>
		</tr>
		
		<tr>
			<th style="width: 200px;">&nbsp;JDK当前版本</th>
			<td id="javaVersion"></td>
		</tr>
		
		<tr>
			<th>&nbsp;系统内存</th>
			<td id="systemTotalMemory"></td>
		</tr>
	</table>
</div>
<div style="position: absolute; left: 650px; top: 495px;"></div>

<div style="position: absolute; left: 593px; top: 135px">
	<table width="400" id="tab_shadow2" bordercolor="#95B8E7" border="1" cellpadding=1px; cellspacing=0px;>
		<tr>
			<th id="thcolor" colspan="2">&nbsp;JVM内存信息</th>
		</tr>
		<tr>
			<th>&nbsp;总共可使用最大内存MB</th>
			<td id="totalRam"></td>
		</tr>
		<tr>
			<th>&nbsp;已使用内存MB</th>
			<td id="usrRam"></td>
		</tr>
		<tr>
			<th>&nbsp;剩余内存MB</th>
			<td id="restRam"></td>
		</tr>
	</table>
</div>
<div id="Ram" style="width: 200px; height: 200px;"></div>
<script src="static/flash/jquery.circliful.min.js"></script>
<script src="static/flash/swfobject.js"></script>
<script>
	var KB = 1024;
	var MB = KB * 1024;
	var GB = MB * 1024;
	
	function ajaxRam() {
		$.ajax({
			url : "getInfo/getRam.do",
			type : 'POST',
			dataType : 'json',
			success : function(jsonObj) {
				$("#usrRam").html(parseInt(jsonObj.used / MB) + "/MB");
				$("#restRam").html(parseInt(jsonObj.free / MB) + "/MB");
				$("#totalRam").html(parseInt(jsonObj.max / MB) + "/MB");
			}
		});
	}
	ajaxRam();
	//setInterval("ajaxRam()", 3000); 
	var diskList;
	var diskIndex = 0;
 	function getPanfu(x) {
		$("#my_chart_div" + diskIndex).remove();
		diskIndex = x;
		$("#my_chart_div" + x).css({
			'display' : 'block'
		});

		var divs = $('<div>');
		divs.attr('id', 'my_chart_div' + x);
		divs.css({
			'position' : 'absolute',
			'left' : '0px',
			'top' : '0px'
		});
		$('#chart_container').append(divs);

		var $div = $('<div>');
		$div.attr('id', 'my_chart' + x);
		$('#my_chart_div' + x).append($div);

		var sf = swfobject.embedSWF("static/flash/open-flash-chart.swf",
				"my_chart" + x, "350", "350", "9.0.0", "expressInstall.swf", {
					"loading" : "正在加载数据,请稍候..."
				});
	}
 
 	function findSWF(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	} 

 	function disk(islinux) {
		$.ajax({
			url : "getInfo/getDisk.do",
			type : 'POST',
			dataType : 'json',
			success : function(jsonObj) {
				diskList = jsonObj;
				if (islinux == "true" || islinux == true) {
					var links = $('<a>');
					links.attr({
						href : 'javascript:void(0);'
					}).html("总硬盘");
					links.css({
						border: '1px solid #AAA', 
						padding: '3px 4px', 
						backgroundColor: '#EEE',
						borderRadius: '3px',
						margin: '0 2px',
						color: '#888'
						});
					$('#fenqu').append(links).css('width', 130 + "px");
				} else {
					for ( var x = 0; x < jsonObj.length; x++) {
						var links = $('<a>');
						links.attr({
							'href' : 'javascript:getPanfu(' + x + ')'
						});
						links.css({
							border: '1px solid #AAA', 
							padding: '3px 4px', 
							backgroundColor: '#EEE',
							borderRadius: '3px',
							margin: '0 2px'
							});
						links.html(jsonObj[x].pf + "&nbsp&nbsp");
						$('#fenqu').append(links);
					}
				}
				getPanfu(diskIndex);
			}
		});
	} 
 	function open_flash_chart_data() {
		setTimeout(function() {
			findSWF("my_chart" + diskIndex).load(getJson(diskIndex));
		}, 0);
		return "";
	} 

 	function getJson(idx) {
		var jsonObj = {};
		//标题
		jsonObj.title = {
			text : "磁盘使用情况",
			style : "{font-size: 20px}"
		};
		jsonObj.bg_colour = "#FFFFFF";
		jsonObj.bg_image = null;

		//数据
		var yy = parseInt(diskList[idx].used / MB);
		var keyong = parseInt(diskList[idx].free / MB);
		var zg = parseInt(diskList[idx].total / MB);
		var shang = parseInt((yy * 100) / zg);
		var keyo = parseInt((keyong * 100) / zg);

		jsonObj.elements = [ {
			"type" : "pie",
			"alpha" : 0.6,
			"start-angle" : "35",
			"animate" : [ {
				"type" : "fade"
			} ],
			"text" : [ "23423424", "@34242" ],
			"tip" : "占据:#val#GB     总共:#total#GB    使用百分比#percent#",
			"colours" : [ '#343AF4', '#F31C28' ],
			"values" : [ {
				"value" : keyong,
				"label" : "可用空间" + keyo + "%"
			}, {
				"value" : yy,
				"label" : "已用空间" + shang + "%"
			} ]
		} ];
		jsonObj.x_axis = null;
		var json = JSON.stringify(jsonObj);
		return json;
	}
 
	$.ajax({
		url : "getInfo/gethardware.do",
		type : 'POST',
		dataType : 'json',
		success : function(jsonObj) {
			$("#javaVersion").html(jsonObj.javaVersion);
			$("#SystemName").html(jsonObj.systemName);
			$("#systemVersion").html(jsonObj.systemVersion);
			$("#systemTotalMemory").html(parseInt(jsonObj.systemTotalMemory/MB) + "/MB");
			disk(jsonObj.isLinux);
		}
	});

</script>